package xyf.p10.dp;

/**
 * ClassName: J014_CutRope
 * Description:
 * Author: xyf
 * Date: 9/9/22 10:29 AM
 * Version: 1.0
 **/
public class J014_CutRope
{
    public int cuttingRope(int n)
    {
        if (n == 0)
        {
            return 0;
        }
        if (n == 1)
        {
            return 1;
        }
        if (n == 2)
        {
            return 1;
        }
        if (n == 3)
        {
            return 2;
        }

        int[] dp = new int[n + 1];
        dp[0] = 1;
        for (int i = 1; i < n + 1; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                dp[i] = Math.max(dp[i], j * dp[i - j]);
            }
        }

        return dp[n];
    }
}